package com.sky.mapper;

import cn.mybatis.mp.core.mybatis.mapper.MybatisMapper;
import com.sky.entity.Users;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
* @author 31827
* @description 针对表【users(用户表)】的数据库操作Mapper
* @createDate 2024-11-21 20:47:21
* @Entity com.sky.entity.Users
*/
@Mapper
public interface UsersMapper extends MybatisMapper<Users> {

    @Select("<script>" +
            "SELECT * FROM users WHERE user_id IN " +
            "<foreach item='item' index='index' collection='list' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    List<Users> selectBatchIds(List<Integer> ids);

    /**
     * 统计指定时间范围内的新增用户数量
     */
    @Select("SELECT COUNT(*) FROM users WHERE registration_date BETWEEN #{startTime} AND #{endTime}")
    Integer countNewUsersByTimeRange(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

}
